package com.googlecode.yoohoo.xmppcore.model.orm;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;

import com.googlecode.yoohoo.xmppcore.model.IXmppCoreModelFactory;
import com.googlecode.yoohoo.xmppcore.model.account.IAccountManager;
import com.googlecode.yoohoo.xmppcore.model.orm.account.AccountManager;

public class Activator implements BundleActivator {
	private ServiceRegistration accountRegistration;
	private ServiceRegistration modelFactoryRegistration;
	
	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		modelFactoryRegistration = context.registerService(IXmppCoreModelFactory.class.getName(),
				new XmppCoreModelFactory(), null);
		accountRegistration = context.registerService(IAccountManager.class.getName(),
				new AccountManager(), null);
	}

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
		accountRegistration.unregister();
		modelFactoryRegistration.unregister();
	}

}
